﻿<%@ WebHandler Language="C#" Class="EmpSettingMgr" %>

using System;
using System.Web;
using System.Text;
using System.Collections.Generic;
using System.Data;
using Chenxin.Lib.Utility;

public class EmpSettingMgr : AjaxHandlerBase
{
    public EmpSettingMgr()
    {
        htTypePermit.Add("del", Constants.Permit_DepartUserDel);
        htTypePermit.Add("delbydep", Constants.Permit_DepartUserDel);
        htTypePermit.Add("edit", Constants.Permit_DepartUserUpdate);
    }

    public override void RequestProcess(HttpContext context)
    {
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";

        string optype = context.Request["op"];
        switch (optype.ToLower())
        {
            case "getlist":
                GetList(context);       //查询数据列表
                break;
            case "getmodel":            //得到单条记录
                GetModel(context);
                break;
            case "del":             //删除设定
                Del(context);
                break;
            case "edit":          //更新设定
                Update(context);
                break;
            case "delbydep":        //删除部门非隶属设定
                DelByDep(context);
                break;
        }        
    }

    //删除部门非隶属设定
    private void DelByDep(HttpContext context)
    {
        try
        {
            string departid = context.Request.Params["departid"];
            string strSql = string.Format("delete Struct_UserDepartRelation where DepartId='{0}' and IsBelong=0", departid);
            Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.ExecuteSQL(strSql);

            AddLog("" + CurrentUserInfo.UserName + "删除业务设定",
                    OperationType.OperationTypeComboList()["OprType_DelEMPSetting"].ToString());
            
            context.Response.Write(string.Format("{{success:'1',msg:'删除成功',data:''}}"));
        }
        catch (Exception ex)
        {
            context.Response.Write(string.Format("{{success:'0',msg:'{0}',data:''}}", ex.Message));
        }
    }
    
    
    //更新设定
    private void Update(HttpContext context)
    {
        try
        {
            Chenxin.Lib.Hr.Entity.Struct_UserDepartRelation model = (Chenxin.Lib.Hr.Entity.Struct_UserDepartRelation)JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.Hr.Entity.Struct_UserDepartRelation));
            if (model.IsBelong)
                model.IsControl = true;
            Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.Update(model);

            AddLog("" + CurrentUserInfo.UserName + "编辑业务设定:员工姓名[" + model.UserName + "(" + model.UserCode + ")]",
                    OperationType.OperationTypeComboList()["OprType_EditEMPSetting"].ToString());
            
            context.Response.Write(string.Format("{{success:'1',msg:'编辑成功',data:''}}"));
        }
        catch (Exception ex)
        {
            context.Response.Write(string.Format("{{success:'0',msg:'{0}',data:''}}", ex.Message));
        }
    }
    
    
    //删除设定
    private void Del(HttpContext context)
    {
        try
        {
            string listid = context.Request.Params["idlist"];
            if (string.IsNullOrEmpty(listid) && context.Request.Params["modelid"].ToString() != "undefined")
                listid = context.Request.Params["modelid"];
           // listid = "'" + listid + "'";
            listid = listid.Replace(",", "','");
            string strSql = string.Format("delete Struct_UserDepartRelation where RecordId in ('{0}') and IsBelong=0;", listid);
            Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.ExecuteSQL(strSql);

            AddLog("" + CurrentUserInfo.UserName + "删除业务设定",
                   OperationType.OperationTypeComboList()["OprType_DelEMPSetting"].ToString());
            
            context.Response.Write(string.Format("{{success:'1',msg:'删除成功',data:''}}"));
        }
        catch (Exception ex)
        {
            context.Response.Write(string.Format("{{success:'0',msg:'{0}',data:''}}", ex.Message));
        }
    }
    

    //得到数据实体
    private void GetModel(HttpContext context)
    {
        try
        {
            string recordid = context.Request.Params["modelid"];
            //根据ID得到变动记录
            Chenxin.Lib.Hr.Entity.Struct_UserDepartRelation usersetting = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.GetModel(new Guid(recordid));
            if (usersetting == null)
            {
                context.Response.Write(string.Format("{{success:'0',msg:'{0}',data:''}}", "参数错误，找不到对应的变动记录"));
            }
            context.Response.Write(string.Format("{{success:'1',msg:'成功',data:{{model:{0}}}}}",
                 Chenxin.Lib.Utility.JsonHelp.Convert2Json(usersetting)));
        }
        catch (Exception ex)
        {
            context.Response.Write(string.Format("{{success:'0',msg:'{0}',data:''}}", ex.Message));
        }
    }

    
    //查询数据列表
    private void GetList(HttpContext context)
    {
        try
        {
            //参数列表
            int iPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
            int iPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数

            //order文
            string strOrder = "Struct_UserDepartRelation.DepartName desc,Struct_UserDepartRelation.IsBelong desc,Struct_UserDepartRelation.usercode asc";
            //查询表格
            string tablename = "Struct_UserDepartRelation";
            //select文
            string TableFieldList = "RecordId,UserCode,UserName,Company,DepartName,CASE WHEN IsBelong='1' THEN '√' ELSE '' END  AS IsBelong,CASE WHEN IsRoleA='1' THEN '√' ELSE '' END  AS IsRoleA,CASE WHEN IsRoleB='1' THEN '√' ELSE '' END  AS IsRoleB,CASE WHEN IsRoleC='1' THEN '√' ELSE '' END  AS IsRoleC,CASE WHEN IsRoleD='1' THEN '√' ELSE '' END  AS IsRoleD,CASE WHEN IsRoleE='1' THEN '√' ELSE '' END  AS IsRoleE,CASE WHEN IsRoleF='1' THEN '√' ELSE '' END  AS IsRoleF,CASE WHEN ViewPubHouse='1' THEN '√' ELSE '' END  AS ViewPubHouse,CASE WHEN ViewPrivHouse='1' THEN '√' ELSE '' END  AS ViewPrivHouse,CASE WHEN ViewHideHouse='1' THEN '√' ELSE '' END  AS ViewHideHouse,CASE WHEN ViewPrivDemand='1' THEN '√' ELSE '' END  AS ViewPrivDemand,CASE WHEN ViewRealCustomer='1' THEN '√' ELSE '' END  AS ViewRealCustomer,CASE WHEN ViewFakeCustomer='1' THEN '√' ELSE '' END  AS ViewFakeCustomer,CASE WHEN EditPrimaryHouse='1' THEN '√' ELSE '' END  AS EditPrimaryHouse,"
    + "CASE WHEN EditNormalHouse='1' THEN '√' ELSE '' END  AS EditNormalHouse,CASE WHEN DelTrace='1' THEN '√' ELSE '' END  AS DelTrace,CASE WHEN CanProtect='1' THEN '√' ELSE '' END  AS CanProtect,CASE WHEN CanLockHouse='1' THEN '√' ELSE '' END  AS CanLockHouse,CASE WHEN ViewLockHouse='1' THEN '√' ELSE '' END  AS ViewLockHouse,CASE WHEN ViewChange='1' THEN '√' ELSE '' END  AS ViewChange,CASE WHEN CanChangeConfirm='1' THEN '√' ELSE '' END  AS CanChangeConfirm,CASE WHEN ViewEntrust='1' THEN '√' ELSE '' END  AS ViewEntrust,CASE WHEN CanCancelTrust='1' THEN '√' ELSE '' END  AS CanCancelTrust,CASE WHEN UnCancelTrust='1' THEN '√' ELSE '' END  AS UnCancelTrust,CASE WHEN CanDelTrust='1' THEN '√' ELSE '' END  AS CanDelTrust,CASE WHEN ViewHrInfo='1' THEN '√' ELSE '' END  AS ViewHrInfo,CASE WHEN ViewHrChange='1' THEN '√' ELSE '' END  AS ViewHrChange,CASE WHEN ViewAttendance='1' THEN '√' ELSE '' END  AS ViewAttendance,"
    + "CASE WHEN ViewWatching='1' THEN '√' ELSE '' END  AS ViewWatching,CASE WHEN EditWatching='1' THEN '√' ELSE '' END  AS EditWatching,CASE WHEN EditKey='1' THEN '√' ELSE '' END  AS EditKey,CASE WHEN UseKey='1' THEN '√' ELSE '' END  AS UseKey,CASE WHEN EditKeyUsing='1' THEN '√' ELSE '' END  AS EditKeyUsing,CASE WHEN EditTrust='1' THEN '√' ELSE '' END  AS EditTrust,CASE WHEN CancelLockHouse='1' THEN '√' ELSE '' END  AS CancelLockHouse,CASE WHEN ViewPrivCustomer='1' THEN '√' ELSE '' END  AS ViewPrivCustomer,CASE WHEN EditPubDemand='1' THEN '√' ELSE '' END  AS EditPubDemand,CASE WHEN EditPrivDemand='1' THEN '√' ELSE '' END  AS EditPrivDemand,CASE WHEN ViewTelLog='1' THEN '√' ELSE '' END  AS ViewTelLog,CASE WHEN ViewBusiness='1' THEN '√' ELSE '' END  AS ViewBusiness,"
    + "CASE WHEN ViewVacation='1' THEN '√' ELSE '' END  AS ViewVacation,CASE WHEN ViewAnnualLeave='1' THEN '√' ELSE '' END  AS ViewAnnualLeave,CASE WHEN ViewUserLog='1' THEN '√' ELSE '' END  AS ViewUserLog,CASE WHEN DelHouse='1' THEN '√' ELSE '' END  AS DelHouse,CASE WHEN EditPubCustomer='1' THEN '√' ELSE '' END  AS EditPubCustomer,CASE WHEN EditPrivCustomer='1' THEN '√' ELSE '' END  AS EditPrivCustomer,CASE WHEN ViewStock='1' THEN '√' ELSE '' END  AS ViewStock,CASE WHEN IsControl='1' THEN '√' ELSE '' END  AS IsControl,"
    + "CASE WHEN ShiftPubCustomer='1' THEN '√' ELSE '' END  AS ShiftPubCustomer,CASE WHEN SetPubLevel='1' THEN '√' ELSE '' END  AS SetPubLevel,CASE WHEN ViewCrossPubShareDemand='1' THEN '√' ELSE '' END  AS ViewCrossPubShareDemand,CASE WHEN ViewPubShareDemand='1' THEN '√' ELSE '' END  AS ViewPubShareDemand,CASE WHEN ViewCrossPubShareCustomer='1' THEN '√' ELSE '' END  AS ViewCrossPubShareCustomer,CASE WHEN ViewPubShareCustomer='1' THEN '√' ELSE '' END  AS ViewPubShareCustomer,CASE WHEN viewtrace='1' THEN '√' ELSE '' END  AS viewtrace,CASE WHEN CanDeletePicture='1' THEN '√' ELSE '' END  AS CanDeletePicture,CASE WHEN CanUploadPicture='1' THEN '√' ELSE '' END  AS CanUploadPicture,CASE WHEN CanPublishHouse='1' THEN '√' ELSE '' END  AS CanPublishHouse";
            string FieldList = "RecordId,UserCode,UserName,Company,DepartName,IsBelong,IsRoleA,IsRoleB,IsRoleC,IsRoleD,IsRoleE,IsRoleF,ViewPubHouse,ViewPrivHouse,ViewHideHouse,ViewPrivDemand,ViewRealCustomer,ViewFakeCustomer,EditPrimaryHouse,EditNormalHouse,DelTrace,CanProtect,CanLockHouse,ViewLockHouse,ViewChange,CanChangeConfirm,ViewEntrust,CanCancelTrust,UnCancelTrust,CanDelTrust,ViewWatching,EditWatching,EditKey,UseKey,EditKeyUsing,EditTrust,CancelLockHouse,ViewPrivCustomer,EditPubDemand,EditPrivDemand,ViewTelLog,ViewBusiness,ViewHrInfo,ViewHrChange,ViewAttendance,ViewVacation,ViewAnnualLeave,ViewUserLog,DelHouse,EditPubCustomer,EditPrivCustomer,ViewStock,IsControl,ShiftPubCustomer,SetPubLevel,ViewCrossPubShareDemand,ViewPubShareDemand,ViewCrossPubShareCustomer,ViewPubShareCustomer,viewtrace,CanDeletePicture,CanUploadPicture,CanPublishHouse";


            //权限
            string strwhere = "";

            Guid cityId = (string.IsNullOrEmpty(context.Request["cityid"])) ? Guid.Empty : new Guid(context.Request["cityid"]);
            Guid companyId = (string.IsNullOrEmpty(context.Request["companyid"])) ? Guid.Empty : new Guid(context.Request["companyid"]);
            Guid areaId = (string.IsNullOrEmpty(context.Request["areaid"])) ? Guid.Empty : new Guid(context.Request["areaId"]);
            Guid departId = (string.IsNullOrEmpty(context.Request["departid"])) ? Guid.Empty : new Guid(context.Request["departid"]);
            Guid userId = (string.IsNullOrEmpty(context.Request["userid"])) ? Guid.Empty : new Guid(context.Request["userid"]);
            string usercode = context.Request["usercode"];

            //判断权限范围/////////////////////////////////////////////
            if (CurrentUserInfo.ContainsPermit(Constants.Permit_UserSetting_All))
            {
                strwhere = " (1=1) ";
            }
            else if (CurrentUserInfo.ContainsPermit(Constants.Permit_UserSetting_City))
            {
                strwhere = string.Format(" (CityId='{0}') ", CurrentUserInfo.CityId.ToString());
            }
            else if (CurrentUserInfo.ContainsPermit(Constants.Permit_UserSetting_Company))
            {
                strwhere = string.Format(" (CompanyId='{0}') ", CurrentUserInfo.CompanyId.ToString());
            }
            else
                strwhere = " (1=0) ";

            if (departId != Guid.Empty)
                strwhere += string.Format(" and DepartId='{0}' ", departId.ToString());
            else if (areaId != Guid.Empty)
            {
                Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item = null;
                string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, areaId);
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                item = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
                if (!cs.Hit)
                {
                    item = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(areaId);
                    if (item != null) cs.Set(strCachkey, item, DateTime.Now.AddDays(1));
                }

                if (item == null) context.Response.Write(string.Format("{{success:'0',msg:'{0}',data:''}}", "获取商圈或分类数据丢失"));

                strwhere += string.Format(" AND (DepartId in (select departId from Hr_DepartmentInfo where DepartSrc like '{0}%')) ", item.DepartSrc);
            }
            else if (companyId != Guid.Empty)
                strwhere += string.Format(" and CompanyId='{0}' ", companyId.ToString());
            else if (cityId != Guid.Empty)
                strwhere += string.Format(" and CityId='{0}' ", cityId.ToString());
            else
                strwhere += string.Format(" and CompanyId='{0}' ", CurrentUserInfo.CompanyId.ToString());
            if (userId != Guid.Empty)
                strwhere += string.Format(" and UserId='{0}' ", userId.ToString());
            if (!string.IsNullOrEmpty(usercode))
                strwhere += string.Format(" and usercode='{0}' ", usercode);
            

            DataSet list = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.GetList(iPageIndex, iPageSize, strOrder, tablename, strwhere, FieldList, TableFieldList, true);

            int count = (int)list.Tables[1].Rows[0][0];
            string strHtml = "";
            if (!GetKeyListHtml(list, out strHtml))
            {
                context.Response.Write(string.Format("{{success:'0',msg:'{0}',data:''}}", "生成HTML错误:" + strHtml));
            }
            list.Dispose();
            list = null;
            context.Response.Write(string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',html:'{2}'}}}}", "成功", count, strHtml));
        }
        catch (Exception ex)
        {
            context.Response.Write(string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message));
        }
    }

    private bool GetKeyListHtml(System.Data.DataSet dslist, out string strHtml)
    {
        try
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            /*
            sb.Append("<table style=\"width:4260px;height:100%;\" cellspacing=\"1\" class=\"tabsorternew\" id=\"report\">");
            sb.Append("<thead><tr>");
            sb.Append("<th width=\"25\"><input type=\"checkbox\" name=\"checkall\" id=\"chk_all\" /></th>");
            sb.Append("<th width=\"100\">工号</th>");
            sb.Append("<th width=\"120\">姓名</th>");
            sb.Append("<th width=\"60\" >公司</th>");
            sb.Append("<th width=\"60\" >部门</th>");
            sb.Append("<th width=\"40\" >隶属</th>");
            sb.Append("<th width=\"40\" >管辖</th>");
            sb.Append("<th width=\"45\" >业务员</th>");
            sb.Append("<th width=\"40\" >秘书</th>");
            sb.Append("<th width=\"40\" >店长</th>");
            sb.Append("<th width=\"40\" >高经</th>");
            sb.Append("<th width=\"40\">区经</th>");
            sb.Append("<th width=\"40\">商经</th>");
            
            sb.Append("<th width=\"40\" >公盘</th>");
            sb.Append("<th width=\"40\" >私盘</th>");
            sb.Append("<th width=\"75\">查隐藏盘源</th>");
            sb.Append("<th width=\"60\">删除房源</th>");

            sb.Append("<th width=\"100\">客源公开级别</th>");

            sb.Append("<th width=\"60\">私客信息</th>");

            sb.Append("<th width=\"150\">查看部门共享客户</th>");
            sb.Append("<th width=\"150\">查看跨部门共享客户</th>");

            sb.Append("<th width=\"100\">转移公开客源</th>");

            sb.Append("<th width=\"60\">修改公客</th>");
            sb.Append("<th width=\"60\">修改私客</th>");

            //sb.Append("<th width=\"60\">公客需求</th>");
            sb.Append("<th width=\"60\">私客需求</th>");

            sb.Append("<th width=\"150\">查看部门共享客需</th>");
            sb.Append("<th width=\"150\">查看跨部门共享客需</th>");

            sb.Append("<th width=\"60\">修改公需</th>");
            sb.Append("<th width=\"60\">修改私需</th>");

            sb.Append("<th width=\"50\">真业主</th>");
            sb.Append("<th width=\"50\">假业主</th>");
            sb.Append("<th width=\"120\">修改房源关键字段</th>");
            sb.Append("<th width=\"130\">修改房源非关键字段</th>");
            sb.Append("<th width=\"60\">删除跟单</th>");
            sb.Append("<th width=\"90\">保护/取消保护</th>");
            sb.Append("<th width=\"60\">封盘操作</th>");
            sb.Append("<th width=\"60\">取消封盘</th>");

            sb.Append("<th width=\"60\">查看封盘</th>");

            sb.Append("<th width=\"60\">查看带看</th>");
            sb.Append("<th width=\"60\">修改带看</th>");
            sb.Append("<th width=\"60\">修改钥匙</th>");
            sb.Append("<th width=\"60\">钥匙使用</th>");
            sb.Append("<th width=\"100\">修改钥匙使用</th>");


            sb.Append("<th width=\"60\">查看变更</th>");
            sb.Append("<th width=\"60\">处理变更</th>");
            sb.Append("<th width=\"60\">查看委托</th>");
            sb.Append("<th width=\"60\">修改委托</th>");

            sb.Append("<th width=\"60\">作废委托</th>");
            sb.Append("<th width=\"60\">取消作废</th>");
            sb.Append("<th width=\"60\">删除委托</th>");

            sb.Append("<th width=\"100\">可查人事信息</th>");
            sb.Append("<th width=\"100\">可查人事变动</th>");
            sb.Append("<th width=\"60\">可查考勤</th>");
            sb.Append("<th width=\"60\">可查休假</th>");
            sb.Append("<th width=\"60\">可查年假</th>");
            sb.Append("<th width=\"60\">可查库存</th>");
            sb.Append("<th width=\"100\">可查电话日志</th>");
            sb.Append("<th width=\"100\">可查营业动态</th>");
            sb.Append("<th width=\"120\">可查用户操作日志</th>");

            sb.Append("</tr></thead><tbody>");*/
            //sb.Append("<tbody>");

            foreach (System.Data.DataRow row in dslist.Tables[0].Rows)
            {
                sb.AppendFormat("<dl id=\"{0}\" class=\"x-grid-row\" >", row["RecordId"].ToString());
                //sb.AppendFormat("<td><input type=\"checkbox\" name=\"chk_record\" id=\"chk_{0}\" /></td>", row["RecordId"].ToString());
                sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "UserCode", ""));
                sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "UserName", ""));
                sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Company", ""));
                sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DepartName", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsBelong", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsControl", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsRoleA", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsRoleF", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsRoleB", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsRoleC", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsRoleD", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsRoleE", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewPubHouse", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewPrivHouse", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewHideHouse", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DelHouse", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SetPubLevel", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewPrivCustomer", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewPubShareCustomer", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewCrossPubShareCustomer", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ShiftPubCustomer", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditPubCustomer", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditPrivCustomer", ""));

                //                sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewPubDemand", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewPrivDemand", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewPubShareDemand", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewCrossPubShareDemand", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditPubDemand", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditPrivDemand", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewRealCustomer", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewFakeCustomer", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditPrimaryHouse", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditNormalHouse", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "viewtrace", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DelTrace", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CanProtect", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CanLockHouse", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CancelLockHouse", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewLockHouse", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewWatching", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditWatching", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditKey", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "UseKey", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditKeyUsing", ""));


                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewChange", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CanChangeConfirm", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewEntrust", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "EditTrust", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CanCancelTrust", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "UnCancelTrust", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CanDelTrust", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewHrInfo", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewHrChange", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewAttendance", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewVacation", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewAnnualLeave", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewStock", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewTelLog", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewBusiness", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ViewUserLog", ""));

                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CanUploadPicture", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CanDeletePicture", ""));
                sb.AppendFormat("<dd style=\"text-align:center;\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CanPublishHouse", ""));

                sb.Append("</dl>");
            }
            //sb.Append("</tbody></table>");
            //sb.Append("</tbody>");
            strHtml = sb.ToString();
            return true;
        }
        catch (Exception ex)
        {
            strHtml = ex.Message;
            return false;
        }
    }
}